<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" :formType="type" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" :cols="4" />
    <FormPanel ref="formPanel1" :list="formList1" :formType="type" @formChange="changeHandle1" :isSubmitBtn="false" :collapse="false" labelWidth="110" :cols="4" />
    <FormPanel ref="formPanel2" :list="formList2" :formType="type" @formChange="changeHandle2" :isSubmitBtn="false" :collapse="false" labelWidth="110" :cols="4" />
    <FormPanel ref="formPanel3" :list="formList3" :formType="type" @formChange="changeHandle3" :isSubmitBtn="false" :collapse="false" labelWidth="110" :cols="4" />
    <FormPanel ref="formPanel4" :list="formList4" :formType="type" :isSubmitBtn="false" :collapse="false" labelWidth="110" :cols="4" />
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
       <el-button type="primary"  v-if="type === 'edit'" @click="updateAudit(1)">审核通过</el-button>
      <el-button type="primary"  v-if="type === 'edit'"  @click="updateAudit(2)">审核驳回</el-button>
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getInfoById,audit } from '@/api/omSale/ActualSales/SalesQuery';

export default {
  mixins: [dictionary],
  props: ['type', 'rowData'],

  data() {
    this.saveData = null;
    this.saveData1 = null;
    this.saveData2 = null;
    this.saveData3 = null;
    this.saveData4 = null;
    return {
      formList: this.createdFrom(),
      formList1: this.createdFrom1(),
      formList2: this.createdFrom2(),
      formList3: this.createdFrom3(),
      formList4: this.createdFrom4(),
      isCan: false,
      isExamine: false,
      empList: [],
      carInfo: {},
      customerInfo: {},
      salesReportInfo: {}
    };
  },
  created(){
    this.formList.forEach((item)=>{
      item.disabled = true
    })
    this.formList1.forEach((item)=>{
      item.disabled = true
    })
    this.formList2.forEach((item)=>{
      item.disabled = true
    })
    this.formList3.forEach((item)=>{
      item.disabled = true
    })
    if(this.type !== 'edit') {
       this.formList4.forEach((item)=>{
      item.disabled = true
    })
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      if (this.type != 'add') {
        this.getDetail();
      }
    },

    async updateAudit(val) {
      let statusParams = {
          actualSalesId:this.rowData.actualSalesId,
          status:val,
      }
      const data = { ...this.$refs.formPanel4.SUBMIT_FORM()}
      // console.log(data.auditOpinion);
      let errStatus = null;
      if (val === 2 && (!data || !data.approvalComments)) {
        this.isExamine = true;
        this.formList4 = this.createdFrom4();
        console.log(this.formList4)
        this.saveData4.approvalComments = data.approvalComments
        let [err, data4] = await this.$refs.formPanel4.GET_FORM_DATA();
        console.log(err)
        errStatus = err;
      }
      statusParams.approvalComments = data.approvalComments
      if (val === 2 && errStatus) return;
      console.log(val === 2 , errStatus,val === 2 && errStatus)
      const res =await audit(statusParams)
      this.closeDrawer()
    },
    // 详细
    async getDetail() {
      const res = await getInfoById(this.rowData.actualSalesId);
      if (res.resultCode == 200) {
        for (let i in res.data) {
          this.formList.map(x => {
            if (x.fieldName == i) {
              x.initialValue = res.data[i];
              if (x.fieldName === 'powerType') {
                this.selectPowerType(res.data[i]);
              }
            }
          });
          this.formList1.map(x => {
            if (x.fieldName == i) {
              x.initialValue = res.data[i];
              if (x.fieldName === 'customerType') {
                this.selectCustomer(res.data[i]);
              }
              if (x.fieldName === 'isVip') {
                this.isSelectVip(res.data[i]);
              }
            }
          });
          this.formList2.map(x => {
            if (x.fieldName == i) {
              x.initialValue = res.data[i];
              if (x.fieldName === 'isRebate') {
                this.isSelectRebate(res.data[i]);
              }
              // if (x.fieldName === 'isReplace') {
              //   this.isSelectReplace(res.data[i]);
              // }
            }
          });
          this.formList3.map(x => {
            if (x.fieldName == i) {
              x.initialValue = res.data[i];
            }
          });
          this.formList4.map(x => {
            if (x.fieldName == i) {
              x.initialValue = res.data[i];
            }
          });
        }
      }
    },
    changeHandle(val) {
      this.saveData = val;
    },
    changeHandle1(val) {
      this.saveData1 = val;
    },
    changeHandle2(val) {
      this.saveData2 = val;
    },
    changeHandle3(val) {
      this.saveData3 = val;
    },
    closeDrawer(type) {
      this.$emit('close', false, type);
    },
    // 客户类型选择
    selectCustomer(val) {
      // 公司 24281002
      console.log(val);
      if (val === 24281002) {
        this.formList1.forEach(item => {
          // item.hidden?!item.hidden:item.hidden
          if (item.hidden) {
            item.hidden = false;
          }
        });
        this.formList1.find(x => x.fieldName == 'sex').rules = [];
        this.formList1.find(x => x.fieldName == 'idTypeCode').rules = [];
        this.formList1.find(x => x.fieldName == 'idNumber').rules = [];
        this.formList1.find(x => x.fieldName == 'identityCardFront').rules = [];
        this.formList1.find(x => x.fieldName == 'identityCardReverse').rules = [];
      } else {
        this.formList1.find(x => x.fieldName == 'sex').rules = [{ required: true, message: '请选择性别', trigger: 'change' }];
        this.formList1.find(x => x.fieldName == 'idTypeCode').rules = [{ required: true, message: '请选择', trigger: 'change' }];
        this.formList1.find(x => x.fieldName == 'idNumber').rules = [{ required: true, message: '请输入', trigger: 'change' }];
        this.formList1.find(x => x.fieldName == 'identityCardFront').rules = [{ required: true, message: '请上传', trigger: 'change' }];
        this.formList1.find(x => x.fieldName == 'identityCardReverse').rules = [{ required: true, message: '请选择.', trigger: 'change' }];
        this.formList1.find(x => x.fieldName == 'companyName').hidden = true;
        this.formList1.find(x => x.fieldName == 'unitContactPersonId').hidden = true;
        this.formList1.find(x => x.fieldName == 'lagalPersonId').hidden = true;
        this.formList1.find(x => x.fieldName == 'lagalPersonName').hidden = true;
        this.formList1.find(x => x.fieldName == 'fax').hidden = true;
        this.formList1.find(x => x.fieldName == 'lagalPersonMobile').hidden = true;
        this.formList1.find(x => x.fieldName == 'legalIdentityCardFront').hidden = true;
        this.formList1.find(x => x.fieldName == 'legalIdentityCardReverse').hidden = true;
        this.formList1.find(x => x.fieldName == 'businessLicense').hidden = true;
        this.formList1.find(x => x.fieldName == 'institutionCode').hidden = true;
        this.formList1.find(x => x.fieldName == 'unitContactMobile').hidden = true;
        this.formList1.find(x => x.fieldName == 'unitContactor').hidden = true;
        this.formList1.find(x => x.fieldName == 'adminAuthorizationFiles').hidden = true;
        this.formList1.find(x => x.fieldName == 'unitContactPersonCardFront').hidden = true;
        this.formList1.find(x => x.fieldName == 'unitContactPersonCardReverse').hidden = true;
      }
    },
    // 是否是大客户
    isSelectVip(val) {
      if (val == 10041001) {
        this.formList1.find(x => x.fieldName == 'bigCustomerFiles').hidden = false;
      } else {
        this.formList1.find(x => x.fieldName == 'bigCustomerFiles').hidden = true;
      }
    },
    // 是否是燃油车
    selectPowerType(val) {
      let arr = [];
      let notArr = [{ required: true, message: '请上传', trigger: 'change' }];
      if (val == 50081001) {
        arr = [{ required: true, message: '请上传', trigger: 'change' }];
        notArr = []
      }
      // // 燃油车必传
      // this.formList2.find(x => x.fieldName == 'holdIdentityCard').rules = arr;
      // this.formList2.find(x => x.fieldName == 'proceduralContract').rules = arr;
      // 电车必传
      this.formList2.find(x => x.fieldName == 'commercialInsuranceFiles').rules = notArr;
      this.formList2.find(x => x.fieldName == 'trafficlInsuranceFiles').rules = notArr;
    },

    isSelectRebate(val) {
      let arr = [];
      if (val == 10041001) {
        arr = [{ required: true, message: '请上传', trigger: 'change' }];
      }
      this.formList2.find(x => x.fieldName == 'rebateFiles').rules = arr;
      console.log('返利' + val);
      console.log(this.formList2.find(x => x.fieldName == 'rebateFiles'));
    },
    isSelectReplace(val) {
      let arr = [];
      if (val == 10041001) {
        arr = [{ required: true, message: '请上传', trigger: 'change' }];
      }
      this.formList2.find(x => x.fieldName == 'replaceFiles').rules = arr;
      console.log('换购' + val);
      console.log(this.formList2.find(x => x.fieldName == 'replaceFiles'));
    },
    showItems1(type) {
      this.formList1.find(x => x.fieldName == 'customerType').initialValue = type;
      if (type == 15231003) {
        this.formList1.find(x => x.fieldName == 'companyLinkMan').hidden = false;
        this.formList1.find(x => x.fieldName == 'companyLinkPhone').hidden = false;
        this.formList1.find(x => x.fieldName == 'corpName').hidden = false;
        this.formList1.find(x => x.fieldName == 'corpMobile').hidden = false;
        this.formList1.find(x => x.fieldName == 'fax').hidden = false;
        return;
      }
      this.formList1.find(x => x.fieldName == 'companyLinkMan').hidden = true;
      this.formList1.find(x => x.fieldName == 'companyLinkPhone').hidden = true;
      this.formList1.find(x => x.fieldName == 'corpName').hidden = true;
      this.formList1.find(x => x.fieldName == 'corpMobile').hidden = true;
      this.formList1.find(x => x.fieldName == 'fax').hidden = true;
    },
    showItems2(type) {
      this.formList2.find(x => x.fieldName == 'payType').initialValue = type;
      if (type == 60151001) {
        this.formList2.find(x => x.fieldName == 'financialInstitution').hidden = false;
        this.formList2.find(x => x.fieldName == 'periodsNumber').hidden = false;
        return;
      }
      this.formList2.find(x => x.fieldName == 'financialInstitution').hidden = true;
      this.formList2.find(x => x.fieldName == 'periodsNumber').hidden = true;
    },
    // 翻译省市区
    transDictText(val, dirtArr) {
      console.log(dirtArr, '---翻译---');
      let res = '';
      if (!val) return res;
      if (Array.isArray(dirtArr)) {
        const target = dirtArr.find(x => x.value == val);
        res = target ? target.text || '' : val;
      }
      return res;
    },
    // ---------------------------车辆信息---------------------------
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '车辆信息'
        },
        {
          type: 'INPUT',
          label: '品牌',
          fieldName: 'brandName',
          initialValue: '',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车系',
          fieldName: 'seriesName',
          initialValue: '',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车型',
          fieldName: 'modelName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配置',
          fieldName: 'configName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '年款',
          fieldName: 'yearModel',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '选装',
          fieldName: 'optionName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '内饰',
          fieldName: 'trimName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '外饰',
          fieldName: 'colorName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '物料编码',
          fieldName: 'productCode',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '物料描述',
          fieldName: 'productName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'SELECT',
          label: '动力类型',
          fieldName: 'powerType',
          disabled: true,
          placeholder: '',
          itemList: this.createDictList('5008'),
        },
        {
          type: 'INPUT',
          label: '销售指导价',
          fieldName: 'directivePrice',
          placeholder: '',
          disabled: true,
          numberFormat: true,
          precision: 2
        },
        {
          type: 'INPUT',
          label: 'VIN',
          fieldName: 'vin',
          initialValue: '',
          disabled: !this.isAdd,
          readonly: true,
          placeholder: '请输入VIN...',
          rules: [{ required: true, message: '请输入VIN...', trigger: 'blur' }],
          unitRender: p => {
            return (
              <div>
                <multiuse-button icon='el-icon-search' onClick={() => this.selectVin()} />
              </div>
            );
          }
        },
        {
          type: 'INPUT',
          label: '发动机号',
          fieldName: 'engineNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '电机号',
          fieldName: 'eleEngineNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '合格证号',
          fieldName: 'certificateNumber',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '电池号',
          fieldName: 'batteryNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '配车日期',
          maxDateTime: new Date(),
          fieldName: 'dispatchedData',
          dateType: 'exactdate',
          format: 'yyyy-MM-dd HH:mm:ss',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '公告号',
          fieldName: 'announcementNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '经销商名称',
          fieldName: 'dealerName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '出库日期',
          maxDateTime: new Date(),
          fieldName: 'latestStockOutDate',
          dateType: 'exactdate',
          format: 'yyyy-MM-dd HH:mm:ss',
          placeholder: '',
          disabled: true
        }
      ];
    },
    // ----------------------------客户信息--------------------------
    createdFrom1() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '客户信息'
        },
        {
          type: 'INPUT',
          label: '零售单号',
          fieldName: 'soNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '客户编号',
          fieldName: 'potentialCustomerNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '客户姓名',
          fieldName: 'customerName',
          maxlength: 36,
          rules: [],
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '客户类型',
          fieldName: 'customerType',
          placeholder: '',
          disabled: true,
          itemList: this.createDictList('2428') || [],
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'sex',
          placeholder: '',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: this.createDictList('1002') || []
        },
        {
          type: 'SELECT',
          label: '证件类型',
          fieldName: 'idTypeCode',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          placeholder: '',
          itemList: this.createDictList('2431') || [],
        },
        {
          type: 'INPUT',
          label: '证件号',
          fieldName: 'idNumber',
          rules: [],
          placeholder: '',
          maxlength: 36,
        },
        {
          type: 'INPUT',
          label: '手机号',
          fieldName: 'customerMobile',
          disabled: true,
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '电话',
          maxlength: 36,
          fieldName: 'customerPhone',
          rules: [],
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '出生日期',
          maxDateTime: new Date(),
          fieldName: 'birthday',
          dateType: 'exactdate',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '年龄段',
          fieldName: 'ageStage',
          placeholder: '',
          itemList: this.createDictList('2429') || []
        },
        {
          type: 'INPUT',
          label: '微信号',
          maxlength: 36,
          rules: [],
          fieldName: 'wechatNo',
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '联系地址',
          rules: [{ required: true, message: '请输入', trigger: 'change' }],
          maxlength: 36,
          fieldName: 'address',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '省份',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          fieldName: 'provinceName',
          initialValue: '',
          style: { width: '150px' },
          itemList: [],
        },
        {
          type: 'SELECT',
          label: '城市',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          fieldName: 'cityName',
          style: { width: '150px' },
          initialValue: '',
          itemList: [],
        },
        {
          type: 'SELECT',
          label: '县区',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          fieldName: 'districtName',
          style: { width: '150px' },
          placeholder: '',
          initialValue: '',
          itemList: []
        },
        {
          type: 'INPUT',
          label: '统一社会信用代码',
          maxlength: 36,
          fieldName: 'institutionCode',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '运营单位联系人',
          maxlength: 36,
          fieldName: 'unitContactor',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '运营单位联系电话',
          maxlength: 36,
          fieldName: 'unitContactMobile',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '企业',
          fieldName: 'companyName',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '授权人身份证号',
          fieldName: 'unitContactPersonId',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            { required: true, message: '请输入正确的身份证号', trigger: 'blur' }
          ],
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '法人身份证号',
          fieldName: 'lagalPersonId',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            { required: true, message: '请输入正确的身份证号', trigger: 'blur' }
          ],
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '法人代表姓名',
          rules: [],
          fieldName: 'lagalPersonName',
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '法人代表手机',
          rules: [],
          fieldName: 'lagalPersonMobile',
          placeholder: ''
        },

        {
          type: 'INPUT',
          maxlength: 36,
          label: '传真',
          // rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          fieldName: 'fax',
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '邮编',
          fieldName: 'zipCode',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '职业',
          fieldName: 'occupationType',
          placeholder: '',
          itemList: this.createDictList('2433') || []
        },
        {
          type: 'SELECT',
          label: '学历',
          fieldName: 'educationLevel',
          placeholder: '',
          itemList: this.createDictList('1035') || []
        },
        {
          type: 'SELECT',
          label: '户口类型',
          fieldName: 'householdType',
          placeholder: '',
          itemList: this.createDictList('2432') || []
        },
        {
          type: 'SELECT',
          label: '单位性质',
          fieldName: 'unitNature',
          placeholder: '',
          itemList: this.createDictList('2434') || []
        },
        {
          type: 'SELECT',
          label: '行业类型',
          fieldName: 'industryType',
          placeholder: '',
          itemList: this.createDictList('2435') || []
        },
        {
          type: 'SELECT',
          label: '客户级别',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          fieldName: 'intentLevel',
          placeholder: '',
          itemList: this.createDictList('2430') || []
        },
        {
          type: 'SELECT',
          label: '婚姻状况',
          fieldName: 'maritalStatus',
          placeholder: '',
          itemList: this.createDictList('2436') || []
        },
        {
          type: 'SELECT',
          label: '家庭年收入',
          fieldName: 'annualHouseholdIncome',
          placeholder: '',
          itemList: this.createDictList('2437') || []
        },
        {
          type: 'SELECT',
          label: '兴趣爱好',
          fieldName: 'hobby',
          placeholder: '',
          itemList: this.createDictList('2440') || []
        },
        {
          type: 'SELECT',
          label: '习惯联系方式',
          fieldName: 'favoriteContactType',
          placeholder: '',
          itemList: this.createDictList('2442') || []
        },
        {
          type: 'SELECT',
          label: '方便联系时段',
          fieldName: 'convenientTime',
          placeholder: '请选择',
          itemList: this.createDictList('2439') || []
        },
        {
          type: 'INPUT',
          label: '使用人',
          maxlength: 36,
          rules: [{ required: true, message: '请输入', trigger: 'change' }],
          fieldName: 'user',
          placeholder: ''
        },
        {
          type: 'INPUT',
          maxlength: 36,
          label: '使用人电话',
          rules: [{ required: true, message: '请输入', trigger: 'change' }],
          fieldName: 'userMobile',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '是否大客户',
          fieldName: 'isVip',
          placeholder: '',
          rules: [{ required: true, message: '请选择 ', trigger: 'change' }],
          itemList: this.createDictList('1004') || [],
        },
        {
          type: 'UPLOAD_FILE',
          label: '身份证正面',
          fieldName: 'identityCardFront',
          selfCols: 2,
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },
        },
        {
          type: 'UPLOAD_FILE',
          label: '身份证反面',
          selfCols: 2,
          fieldName: 'identityCardReverse',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '法人身份证正面',
          selfCols: 2,
          fieldName: 'legalIdentityCardFront',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '法人身份证反面',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          fieldName: 'legalIdentityCardReverse',
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '营业执照',
          fieldName: 'businessLicense',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '管理员授权文件',
          fieldName: 'adminAuthorizationFiles',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '授权人身份证正面',
          fieldName: 'unitContactPersonCardFront',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '授权人身份证反面',
          fieldName: 'unitContactPersonCardReverse',
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '大客户附件',
          fieldName: 'bigCustomerFiles',
          hidden: true,
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        }
      ];
    },
    // ----------------------------销售信息--------------------------
    createdFrom2() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '销售信息'
        },
        {
          type: 'SELECT',
          label: '购车用途',
          fieldName: 'purchasePurpose',
          rules: [{ required: true, message: '请选择 ', trigger: 'change' }],
          placeholder: '',
          itemList: this.createDictList('2438') || []
        },
        {
          type: 'INPUT',
          label: '销售顾问',
          disabled: true,
          fieldName: 'consultantName',
          placeholder: ''
        },
        {
          type: 'INPUT_NUMBER',
          label: '购车价格',
          disabled: true,
          fieldName: 'orderAllAmount',
          maxlength: 9,
          placeholder: '',
          numberFormat: true,
          precision: 0
        },
        {
          type: 'DATE',
          label: '交车日期',
          disabled: true,
          maxDateTime: new Date(),
          dateType: 'exactdate',
          format: 'yyyy-MM-dd HH:mm:ss',
          fieldName: 'handoverCarTime',
          dateType: 'exactdate',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '订单创建日期',
          maxDateTime: new Date(),
          disabled: true,
          fieldName: 'snCreatedDate',
          dateType: 'exactdate',
          format: 'yyyy-MM-dd HH:mm:ss',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '开票日期',
          rules: [{ required: true, message: '请选择 ', trigger: 'change' }],
          maxDateTime: new Date(),
          fieldName: 'drawTime',
          dateType: 'exactdate',
          format: 'yyyy-MM-dd',
          placeholder: ''
        },
        {
          type: 'INPUT_NUMBER',
          min: 0,
          label: '开票金额',
          rules: [{ required: true, message: '请选择 ', trigger: 'change' }],
          fieldName: 'totalaMount',
          maxlength: 8,
          precision: 0,
          placeholder: ''
        },
        {
          type: 'INPUT',
          label: '发票号',
          rules: [{ required: true, message: '请选择 ', trigger: 'change' }],
          fieldName: 'invoiceNo',
          placeholder: ''
        },

        // {
        //   type: 'SELECT',
        //   label: '特殊订单',
        //   fieldName: 'isSpecialOrder',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || []
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否三包',
        //   fieldName: 'isThreeGuarantees',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || []
        // },
        {
          type: 'SELECT',
          label: '是否异地购车',
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
          fieldName: 'isAnotherPlace',
          placeholder: '',
          itemList: this.createDictList('1004') || []
        },
        {
          type: 'INPUT_NUMBER',
          min: 0,
          label: '交车里程',
          maxlength: 8,
          precision: 0,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          fieldName: 'mileageUid',
          placeholder: ''
        },
        // {
        //   type: 'SELECT',
        //   label: '是否建设电桩',
        //   fieldName: 'buildChargingPiles',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || []
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否申报补贴',
        //   fieldName: 'isApplySubsidies',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || []
        // },
        // {
        //   type: 'SELECT',
        //   label: '是否融资返利',
        //   fieldName: 'isRebate',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || [],
        //   change: val => {
        //     this.isSelectRebate(val);
        //   }
        // },
        {
          type: 'SELECT',
          label: '是否增换购',
          fieldName: 'isReplace',
          placeholder: '',
          itemList: this.createDictList('1004') || []
          // change: val => {
          //   this.isSelectReplace(val);
          // }
        },
        // {
        //   type: 'SELECT',
        //   label: '是否销量冲刺',
        //   fieldName: 'isSalesSprint',
        //   placeholder: '',
        //   itemList: this.createDictList('1004') || []
        // },
        {
          type: 'SELECT',
          label: '是否二次购买',
          fieldName: 'isBuyAgain',
          placeholder: '',
          itemList: this.createDictList('1004') || []
        },
        {
          type: 'SELECT',
          label: '是否电池租赁',
          // offsetRightCols: 2,
          rules: [],
          fieldName: 'isBatteryRental',
          placeholder: '',
          itemList: this.createDictList('1004') || []
        },

        {
          type: 'TEXT_AREA',
          label: '备注',
          offsetRightCols: 1,
          maxlength: 600,
          fieldName: 'remark',
          placeholder: '',
          selfCols: 3
        },
        {
          type: 'UPLOAD_FILE',
          label: '发票附件',
          fieldName: 'invoiceUidList',
          selfCols: 2,
          rules: [{ required: true, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '终端销售合同',
          selfCols: 2,
          fieldName: 'terminalSalesContract',
          // rules: [{ required: true, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '过程性合同',
          fieldName: 'proceduralContract',
          selfCols: 2,
          rules: [],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '手持身份证照片',
          fieldName: 'holdIdentityCard',
          selfCols: 2,
          rules: [],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '商业保险单',
          // disabled: true,
          fieldName: 'commercialInsuranceFiles',
          selfCols: 2,
          rules: [],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '交强保险单',
          // disabled: true,
          fieldName: 'trafficlInsuranceFiles',
          selfCols: 2,
          rules: [],
          // selfCols: 3,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        // {
        //   type: 'UPLOAD_FILE',
        //   label: '融资返利文件',
        //   // disabled: true,
        //   fieldName: 'rebateFiles',
        //   selfCols: 2,
        //   rules: [],
        //   // selfCols: 3,
        //   upload: {
        //     actionUrl: '/api/file/oss/upload',
        //     fileTypes: ['jpg', 'png', 'pdf'],
        //     limit: 2
        //     // tipText: '最多上传1个附件'
        //   }
        // },
        {
          type: 'UPLOAD_FILE',
          label: '增换购附件',
          // disabled: true,
          fieldName: 'replaceFiles',
          selfCols: 2,
          rules: [],
          // selfCols: 3,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf', 'xls', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '其他附件',
          fieldName: 'attachmentUidsList',
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'xls', 'pdf', 'xlsx', 'rar', 'zip'],
            limit: 10
          },

        }
      ];
    },
    // ----------------------------上牌信息--------------------------
    createdFrom3() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '上牌信息'
        },
        {
          type: 'INPUT',
          label: '车牌号',
          rules: [{ required: true, message: '请输入正确的车牌号', trigger: 'blur' }],
          maxlength: 8,
          fieldName: 'licensePlateNumber',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '上牌日期',
          maxDateTime: new Date(),
          fieldName: 'licensePlateDate',
          dateType: 'exactdate',
          disabled: false,
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '行驶证车辆性质',
          fieldName: 'licenseVehicleNature',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          placeholder: '',
          itemList: this.createDictList('2425')
        },
        {
          type: 'SELECT',
          label: '上牌省份',
          fieldName: 'licensePlateProvinceName',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          placeholder: '',
          // itemList: this.createRegionsList()
          itemList: [],
        },
        {
          type: 'SELECT',
          label: '上牌城市',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          fieldName: 'licensePlateCityName',
          placeholder: '',
          itemList: []
        },
        {
          type: 'INPUT',
          label: '行驶证号',
          maxlength: 36,
          fieldName: 'vehicleLicenseNumber',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            { required: true, message: '请输入正确的行驶证号', trigger: 'blur' }
          ],
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '行驶证注册日期',
          maxDateTime: new Date(),
          fieldName: 'vehicleLicenseDate',
          disabled: false,
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
          dateType: 'exactdate',
          placeholder: ''
        },
        {
          type: 'DATE',
          label: '行驶证发证日期',
          maxDateTime: new Date(),
          fieldName: 'vehicleLicenseIssueDate',
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
          dateType: 'exactdate',
          placeholder: ''
        },
        // {
        //   type: 'INPUT',
        //   label: '行驶证档案编号',
        //   fieldName: 'vehicleLicenseFileNo',
        //   rules: [{ required: true, message: '请选择', trigger: 'blur' }],
        //   placeholder: '',
        //   disabled: false
        // },
        {
          type: 'INPUT',
          label: '行驶证住址',
          maxlength: 36,
          fieldName: 'vehicleLicenseAddress',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          placeholder: ''
        },

        {
          type: 'INPUT',
          label: '驾驶证号',
          maxlength: 36,
          rules: [{ min: 0, max: 20, message: '驾驶证号输入有误，请检查', trigger: 'blur' }],
          fieldName: 'drivingLicenseNumber',
          placeholder: ''
        },

        {
          type: 'INPUT_NUMBER',
          label: '行驶里程',
          precision: 0,
          maxlength: 8,
          fieldName: 'mileage',
          placeholder: ''
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          offsetRightCols: 1,
          maxlength: 600,
          fieldName: 'licenseRemark',
          placeholder: '',
          selfCols: 3
        },
        {
          type: 'UPLOAD_FILE',
          label: '行驶证正面',
          fieldName: 'vehicleLicenseFrontList',
          selfCols: 2,
          rules: [{ required: true, message: '请上传', trigger: 'blur' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'bmp'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '行驶证反面',
          selfCols: 2,
          fieldName: 'vehicleLicenseBackList',
          rules: [{ required: true, message: '请上传', trigger: 'blur' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'bmp'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '驾驶证正面',
          selfCols: 2,
          fieldName: 'drivingLicenseFrontList',
          // selfCols: 3,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'bmp'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '驾驶证反页',
          selfCols: 2,
          fieldName: 'drivingLicenseBackList',
          // selfCols: 3,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'bmp'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        },
        {
          type: 'UPLOAD_FILE',
          label: '其他附件',
          fieldName: 'otherFileUrlList',
          selfCols: 2,
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'xls', 'pdf', 'xlsx', 'rar', 'zip'],
            limit: 1,
            tipText: '最多上传1个附件'
          },

        }
      ];
    },
     // ----------------------------其他信息--------------------------
    createdFrom4() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '其他信息'
        },
        {
          type: 'TEXT_AREA',
          label: '审批意见',
          fieldName: 'approvalComments',
           maxlength: 120,
          placeholder: '',
          rules: this.isExamine ? [{ required: true, message: '请输入审批意见', trigger: 'blur' }] : [],
          selfCols: 3
        }
      ]
    }
  }
};
</script>
